module rm {
	/**
	 * Create by richliu1023
	 * @date 2016-06-06
	 * @email richliu1023@gmail.com
	 * @github https://github.com/RichLiu1023
	 * @description a simple explanation
	 */
	export class CameraController {
		private static _cameraCtl:rm.HoverController = null;
		private static _targetObj:egret3d.Object3D = null;

		public constructor() {
		}

		public static setup( canvas3d:egret3d.Camera3D ):void {
			this._cameraCtl = new rm.HoverController( canvas3d, null, 0, 0, 1000 );
			this._cameraCtl.lookAtPosition = new egret3d.Vector3D( 0, 0, 0 );
		}

		public static setLookAtObject( targetObj:egret3d.Object3D ):void {
			this._targetObj = targetObj;
		}

		public static update( interpolate:boolean = true ):void {
			if ( !this._cameraCtl )return;
			if ( this._targetObj ) {
				this._cameraCtl.lookAtPosition = this._targetObj.position;
			}
			this._cameraCtl.update( false );
		}

		public static getLookAtObject():egret3d.Object3D {
			return this._targetObj;
		}

		public static get distance():number {
			if ( this._cameraCtl ) {
				return this._cameraCtl.distance;
			}
			return 0;
		}

		public static set distance( value:number ) {
			if ( this._cameraCtl ) {
				this._cameraCtl.distance = value;
			}
		}

		public static get yAngle():number {
			if ( this._cameraCtl ) {
				return this._cameraCtl.panAngle;
			}
			return 0;
		}

		public static set yAngle( value:number ) {
			if ( this._cameraCtl ) {
				this._cameraCtl.panAngle = value;
			}
		}

		public static get xAngle():number {
			if ( this._cameraCtl ) {
				return this._cameraCtl.tiltAngle;
			}
			return 0;
		}

		public static set xAngle( value:number ) {
			if ( this._cameraCtl ) {
				this._cameraCtl.tiltAngle = value;
			}
		}

		public static set isOpenFree( value:boolean ) {
			this._cameraCtl.isOpenFree = value;
		}

		public static get isOpenFree():boolean {
			return this._cameraCtl.isOpenFree;
		}
	}
}